#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=100000+5;
int n,qqq,x,cha;
int type;
int y;
struct Node
{
	int num;
	int bh,ans;
}a[N];
bool cmp(Node aa,Node bb)
{
	if (aa.num==bb.num) return aa.bh<bb.bh;
	return aa.num<bb.num;
}
bool cmp1(Node aa,Node bb)
{
	return aa.bh<bb.bh;
}
bool pd(int x,int le,int ri,int who)
{
	if (le<a[who].num&&a[who].num<ri) return 1;
	if (le==a[who].num&&x<who) return 1;
	if (ri==a[who].num&&who<x) return 1;
	return 0;
}
int main()
{
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	cin>>n>>qqq;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i].num);
		a[i].bh=i;
	}
	sort(a+1,a+1+n,cmp);
	for (int i=1;i<=n;i++)  a[i].ans=i;
	sort(a+1,a+1+n,cmp1);
	for (int i=1;i<=qqq;i++)
	{
		scanf("%d",&type);
		if (type==1)
		{
			scanf("%d %d",&x,&y);
			if (a[x].num<y)
			{
				cha=0;
				for (int j=1;j<=n;j++)
				  if (x!=j&&pd(x,a[x].num,y,j))
				    a[j].ans--,cha++;
				a[x].ans+=cha;
				a[x].num=y;
			} else
			if (a[x].num>y)
			{
				cha=0;
				for (int j=1;j<=n;j++)
				  if (x!=j&&pd(x,y,a[x].num,j))
				    a[j].ans++,cha++;
				a[x].ans-=cha;
				a[x].num=y;
			}
		} else
		if (type==2)
		{
			scanf("%d",&x);
			printf("%d\n",a[x].ans);
		}
	}
	return 0;
}
